import Mock from 'mockjs'
import {fa, fakerZH_CN as faker} from "@faker-js/faker";

const mockMap = {
	// 中文姓名
	'chinese_name': () => Mock.mock('@cname'),
	// 中国身份证号
	'chinese_id_number': () => {
		return Mock.mock({
			'regexp': /^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X)$/
		}).regexp
	},
	// 邮箱
	'email': () => Mock.mock('@email'),
	// 中国手机号
	'chinese_phone_number': () => {
		return Mock.mock({
			'regexp': /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[01256789]))\d{8}$/
		}).regexp
	},
	// 邮政编码
	'postal_code': () => {
		return Mock.mock({
			'regexp': /^(0[1-7]|1[0-356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[0-5]|8[013-6])\d{4}$/
		}).regexp
	},
	// 省市区/县
	'chinese_county': () => Mock.mock('@county(true)').replaceAll(' ', ''),
	// 中国地址
	'chinese_address': () => {
		const address = `${Mock.mock('@county(true)')}${faker.location.streetAddress({useFullAddress: true})}`
		return address.replaceAll(' ', '')
	},
	// UUID
	'uuid': () => Mock.mock('@uuid'),
	// GUID
	'guid': () => Mock.mock('@guid'),
	// IP
	'ip': () => faker.internet.ip(),
	// IPv4
	'ipv4': () => faker.internet.ipv4(),
	// IPv6
	'ipv6': () => faker.internet.ipv6(),
	// 中文段落
	'chinese_paragraph': () => Mock.mock('@cparagraph'),
	// 公司名称
	'company_name': () => faker.company.name(),
};

const type = process.argv[2];
let result = mockMap[type]?.();
result = result?.replace(/\r\n|(?<!\r\n)\n(?!\r\n)|(?<!\r\n|\n)\r(?!\r\n|\n)/, '')

console.log(result || '暂不支持该类型');
